﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text;

namespace YAPL.Language.Ast.Utils {

	/// <summary>
	/// The exception that is thrown when DescendantAttribute is applied to invalid property
	/// </summary>
	public class InvalidDescendantException : ApplicationException {
		private readonly PropertyInfo _descendantProperty;
		public InvalidDescendantException(PropertyInfo descendantProperty) {
			_descendantProperty = descendantProperty;
		}

		public InvalidDescendantException(string message, PropertyInfo descendantProperty) : base(message) {
			_descendantProperty = descendantProperty;
		}

		public InvalidDescendantException(string message, Exception innerException, PropertyInfo descendantProperty) : base(message, innerException) {
			_descendantProperty = descendantProperty;
		}

		protected InvalidDescendantException(SerializationInfo info, StreamingContext context, PropertyInfo descendantProperty) : base(info, context) {
			_descendantProperty = descendantProperty;
		}

		public PropertyInfo DescendantProperty {
			get { return _descendantProperty; }
		}
	}
}
